﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using EZMemoLib;
using System.Windows.Media.Animation;

namespace Remember.WPF.Views
{
    /// <summary>
    /// Interaction logic for LoginList.xaml
    /// </summary>
    public partial class LoginItem : UserControl
    {
        public event EventHandler OnStart;
        public event EventHandler OnRemove;

        public LoginItem()
        {
            InitializeComponent();
        }
        private MemoLogin _Login = null;
        public LoginItem( MemoLogin login): this()
        {
            _Login = login;
            Bind();
        }

        void Bind()
        {
            if (_Login != null)
            {
                uiLoginName.Text = _Login.LoginName;
            }
        }

        private void ButtonRemove_Click(object sender, RoutedEventArgs e)
        {
            if (OnRemove != null)
            {
                OnRemove(_Login, e);
            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (OnStart != null)
            {
                OnStart(_Login, e);
            }
        }

        private void borderLogin_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            //this.Height = 200;
            //this.borderLogin.Height = 120;
            //var animFadeIn = new DoubleAnimation();
            //animFadeIn.From = 100;
            //animFadeIn.To = 200;
            //animFadeIn.Duration = new Duration(TimeSpan.FromMilliseconds(1500));
            //this.BeginAnimation( HeightProperty , animFadeIn);

            //animFadeIn.From = 56;
            //animFadeIn.To = 100;
            //animFadeIn.Duration = new Duration(TimeSpan.FromMilliseconds(1500));
            //this.borderLogin.BeginAnimation(HeightProperty, animFadeIn);

            //return;
 
            if (OnStart != null)
            {
                OnStart(_Login, e);
            }
        }

        Brush borderBrush = null;
        private void borderLogin_MouseEnter(object sender, MouseEventArgs e)
        {
            borderBrush = this.borderLogin.BorderBrush;
            this.borderLogin.BorderBrush = new SolidColorBrush(Colors.LimeGreen);

            uiLoginStart.TextDecorations = TextDecorations.Underline;
        }

        private void borderLogin_MouseLeave(object sender, MouseEventArgs e)
        {
            uiLoginStart.TextDecorations = null;
            if (borderBrush != null)
            {
                this.borderLogin.BorderBrush = borderBrush as SolidColorBrush;
            }
        }

    }
}
